/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package hojatrabajo1;

import java.text.DecimalFormat;

/*
 * UsoRadio.java
 * 
 * 
 * 
 * 
 * //*******************************************************************
// Autor:   Yimy Juarez - 11389
//          Eddy Castro - 11032
//          Rodrigo Medrano - 11222
// Seccion: 10
// Nombre del Archivo: UsoRadio.java
// Fecha de Modificacion:09/07/2012
// Descripcion:
// Interfaz grafica del radio, utilizado la clase Radio.java
// *********************************************************************
 *
 * Created on Jul 9, 2012, 5:11:39 PM
 */

/**
 *
 * @author eddy
 * @author rodrigo
 * @author yimy
 */
public class UsoRadio extends javax.swing.JFrame {

    
    //Nuevo objeto radio
    iRadio radio = new Radio();
    
    
    //Formato para AM y FM
    DecimalFormat amformat = new DecimalFormat("###");
    DecimalFormat fmformat = new DecimalFormat("##.#");
    
    
    /** Creates new form UsoRadio */
    public UsoRadio() {
        initComponents();
    
        
        //Agregar botones al grupo de estaciones
        grp_estacion.add(opt_am);
        grp_estacion.add(opt_fm);
        
        //metodo obligado para que exista una memoria, no existe metodo setFreq()
        for (int i = 1;i <= 12;i++){
            radio.SaveFreq(i);
        }
        
        radio.ChangeSignal();
        
        for (int i = 1;i <= 12;i++){
            radio.SaveFreq(i);
        }
        
        if (!radio.IsAm()){
             radio.ChangeSignal();
        }
        
        
        //Formato para impresion de estaciones
        if (radio.IsAm()){
            textEstacion.setText(String.valueOf(amformat.format(radio.GetFreq())));
        }
        else{
            textEstacion.setText(String.valueOf(fmformat.format(radio.GetFreq())));
        }
        
            
    }
       
    //Procedimiento para encender radio
    private void Habilitar(){
        m1.setEnabled(true);
        m2.setEnabled(true);
        m3.setEnabled(true);
        m4.setEnabled(true);
        m5.setEnabled(true);
        m6.setEnabled(true);
        m7.setEnabled(true);
        m8.setEnabled(true);
        m9.setEnabled(true);
        m10.setEnabled(true);
        m11.setEnabled(true);
        m12.setEnabled(true);
        opt_am.setEnabled(true);
        opt_fm.setEnabled(true);
        next.setEnabled(true);
        botones.setEnabled(true);
        guardar.setEnabled(true);
    }
    
    //Procedimiento para apagar la radio
    private void Deshabilitar(){
        m1.setEnabled(false);   
        m2.setEnabled(false);
        m3.setEnabled(false);
        m4.setEnabled(false);
        m5.setEnabled(false);
        m6.setEnabled(false);
        m7.setEnabled(false);
        m8.setEnabled(false);
        m9.setEnabled(false);
        m10.setEnabled(false);
        m11.setEnabled(false);
        m12.setEnabled(false);
        opt_am.setEnabled(false);
        opt_fm.setEnabled(false);
        next.setEnabled(false);
        botones.setEnabled(false);
        guardar.setEnabled(false);
    }
    

    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        grp_estacion = new javax.swing.ButtonGroup();
        panel2 = new javax.swing.JPanel();
        m1 = new javax.swing.JButton();
        m2 = new javax.swing.JButton();
        m3 = new javax.swing.JButton();
        m4 = new javax.swing.JButton();
        m5 = new javax.swing.JButton();
        m6 = new javax.swing.JButton();
        m7 = new javax.swing.JButton();
        m8 = new javax.swing.JButton();
        m9 = new javax.swing.JButton();
        m10 = new javax.swing.JButton();
        m11 = new javax.swing.JButton();
        m12 = new javax.swing.JButton();
        panel1 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        textEstacion = new javax.swing.JTextField();
        panel3 = new javax.swing.JPanel();
        power = new javax.swing.JToggleButton();
        next = new javax.swing.JButton();
        opt_fm = new javax.swing.JRadioButton();
        opt_am = new javax.swing.JRadioButton();
        jPanel1 = new javax.swing.JPanel();
        botones = new javax.swing.JComboBox();
        guardar = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Radio");
        setBackground(new java.awt.Color(51, 51, 51));

        panel2.setBackground(new java.awt.Color(0, 0, 255));
        panel2.setName("panel2"); // NOI18N

        m1.setText("01");
        m1.setEnabled(false);
        m1.setName("m1"); // NOI18N
        m1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                m1ActionPerformed(evt);
            }
        });

        m2.setText("02");
        m2.setEnabled(false);
        m2.setName("m2"); // NOI18N
        m2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                m2ActionPerformed(evt);
            }
        });

        m3.setText("03");
        m3.setEnabled(false);
        m3.setName("m3"); // NOI18N
        m3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                m3ActionPerformed(evt);
            }
        });

        m4.setText("04");
        m4.setEnabled(false);
        m4.setName("m4"); // NOI18N
        m4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                m4ActionPerformed(evt);
            }
        });

        m5.setText("05");
        m5.setEnabled(false);
        m5.setName("m5"); // NOI18N
        m5.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                m5ActionPerformed(evt);
            }
        });

        m6.setText("06");
        m6.setEnabled(false);
        m6.setName("m6"); // NOI18N
        m6.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                m6ActionPerformed(evt);
            }
        });

        m7.setText("07");
        m7.setEnabled(false);
        m7.setName("m7"); // NOI18N
        m7.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                m7ActionPerformed(evt);
            }
        });

        m8.setText("08");
        m8.setEnabled(false);
        m8.setName("m8"); // NOI18N
        m8.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                m8ActionPerformed(evt);
            }
        });

        m9.setText("09");
        m9.setEnabled(false);
        m9.setName("m9"); // NOI18N
        m9.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                m9ActionPerformed(evt);
            }
        });

        m10.setText("10");
        m10.setEnabled(false);
        m10.setName("m10"); // NOI18N
        m10.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                m10ActionPerformed(evt);
            }
        });

        m11.setText("11");
        m11.setEnabled(false);
        m11.setName("m11"); // NOI18N
        m11.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                m11ActionPerformed(evt);
            }
        });

        m12.setText("12");
        m12.setEnabled(false);
        m12.setName("m12"); // NOI18N
        m12.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                m12ActionPerformed(evt);
            }
        });

        org.jdesktop.layout.GroupLayout panel2Layout = new org.jdesktop.layout.GroupLayout(panel2);
        panel2.setLayout(panel2Layout);
        panel2Layout.setHorizontalGroup(
            panel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(panel2Layout.createSequentialGroup()
                .addContainerGap()
                .add(panel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(panel2Layout.createSequentialGroup()
                        .add(m2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 49, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
                        .add(m4, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 49, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
                        .add(m6, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 49, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
                        .add(m8, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 49, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
                        .add(m10, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 49, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
                        .add(m12, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 49, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                    .add(panel2Layout.createSequentialGroup()
                        .add(m1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 49, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
                        .add(m3, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 49, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
                        .add(m5, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 49, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
                        .add(m7, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 49, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
                        .add(m9, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 49, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
                        .add(m11, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 49, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        panel2Layout.setVerticalGroup(
            panel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(panel2Layout.createSequentialGroup()
                .addContainerGap()
                .add(panel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(m3)
                    .add(m5)
                    .add(m7)
                    .add(m1)
                    .add(m9)
                    .add(m11))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(panel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(m4)
                    .add(m6)
                    .add(m8)
                    .add(m2)
                    .add(m10)
                    .add(m12))
                .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        panel1.setBackground(new java.awt.Color(153, 0, 0));
        panel1.setName("panel1"); // NOI18N

        jLabel1.setFont(new java.awt.Font("Lucida Grande", 1, 18));
        jLabel1.setText("Radio");
        jLabel1.setName("jLabel1"); // NOI18N

        textEstacion.setFont(new java.awt.Font("Lucida Grande", 0, 16)); // NOI18N
        textEstacion.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        textEstacion.setEnabled(false);
        textEstacion.setName("textEstacion"); // NOI18N

        org.jdesktop.layout.GroupLayout panel1Layout = new org.jdesktop.layout.GroupLayout(panel1);
        panel1.setLayout(panel1Layout);
        panel1Layout.setHorizontalGroup(
            panel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(panel1Layout.createSequentialGroup()
                .addContainerGap()
                .add(panel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(textEstacion, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 79, Short.MAX_VALUE)
                    .add(jLabel1))
                .addContainerGap())
        );
        panel1Layout.setVerticalGroup(
            panel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(panel1Layout.createSequentialGroup()
                .addContainerGap()
                .add(jLabel1)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(textEstacion)
                .addContainerGap())
        );

        panel3.setBackground(new java.awt.Color(255, 255, 255));
        panel3.setName("panel3"); // NOI18N

        power.setBackground(new java.awt.Color(204, 0, 0));
        power.setText("POWER");
        power.setName("power"); // NOI18N
        power.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                powerMouseClicked(evt);
            }
        });

        next.setText("NEXT");
        next.setEnabled(false);
        next.setName("next"); // NOI18N
        next.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                nextActionPerformed(evt);
            }
        });

        opt_fm.setText("FM");
        opt_fm.setEnabled(false);
        opt_fm.setName("opt_fm"); // NOI18N
        opt_fm.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                opt_fmMouseClicked(evt);
            }
        });
        opt_fm.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                opt_fmActionPerformed(evt);
            }
        });

        opt_am.setSelected(true);
        opt_am.setText("AM");
        opt_am.setEnabled(false);
        opt_am.setName("opt_am"); // NOI18N
        opt_am.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                opt_amMouseClicked(evt);
            }
        });
        opt_am.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                opt_amActionPerformed(evt);
            }
        });

        org.jdesktop.layout.GroupLayout panel3Layout = new org.jdesktop.layout.GroupLayout(panel3);
        panel3.setLayout(panel3Layout);
        panel3Layout.setHorizontalGroup(
            panel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(panel3Layout.createSequentialGroup()
                .addContainerGap()
                .add(panel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(opt_am)
                    .add(opt_fm))
                .add(18, 18, 18)
                .add(panel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(next, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 105, Short.MAX_VALUE)
                    .add(power, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 105, Short.MAX_VALUE))
                .addContainerGap())
        );
        panel3Layout.setVerticalGroup(
            panel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(panel3Layout.createSequentialGroup()
                .addContainerGap()
                .add(panel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(opt_am)
                    .add(power))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(panel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(opt_fm)
                    .add(next))
                .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel1.setBackground(new java.awt.Color(102, 102, 102));
        jPanel1.setName("jPanel1"); // NOI18N

        botones.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12" }));
        botones.setEnabled(false);
        botones.setName("botones"); // NOI18N

        guardar.setText("Guardar");
        guardar.setEnabled(false);
        guardar.setName("guardar"); // NOI18N
        guardar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                guardarActionPerformed(evt);
            }
        });

        org.jdesktop.layout.GroupLayout jPanel1Layout = new org.jdesktop.layout.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .add(botones, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 90, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 111, Short.MAX_VALUE)
                .add(guardar)
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(botones, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(guardar))
                .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                    .add(org.jdesktop.layout.GroupLayout.LEADING, jPanel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .add(org.jdesktop.layout.GroupLayout.LEADING, layout.createSequentialGroup()
                        .add(panel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(panel3, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                    .add(org.jdesktop.layout.GroupLayout.LEADING, panel2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .addContainerGap()
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                    .add(panel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 96, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(panel3, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(panel2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jPanel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void powerMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_powerMouseClicked
        if (power.isSelected()==true){
            Habilitar();
        }
        else
        {
            Deshabilitar();
        }// TODO add your handling code here:
    }//GEN-LAST:event_powerMouseClicked

    private void opt_amMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_opt_amMouseClicked
        //radio.ChangeSignal(); 
        //textEstacion.setText(String.valueOf(radio.GetFreq()));// TODO add your handling code here:
    }//GEN-LAST:event_opt_amMouseClicked

    private void opt_fmMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_opt_fmMouseClicked
        //radio.ChangeSignal();
        //textEstacion.setText(String.valueOf(radio.GetFreq()));// TODO add your handling code here:
    }//GEN-LAST:event_opt_fmMouseClicked

    private void opt_amActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_opt_amActionPerformed
        radio.ChangeSignal(); // TODO add your handling code here:
        if (radio.IsAm()){
            textEstacion.setText(String.valueOf(amformat.format(radio.GetFreq())));
        }
        else{
            textEstacion.setText(String.valueOf(fmformat.format(radio.GetFreq())));
        }
    }//GEN-LAST:event_opt_amActionPerformed

    private void opt_fmActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_opt_fmActionPerformed
        radio.ChangeSignal();    
        if (radio.IsAm()){
            textEstacion.setText(String.valueOf(amformat.format(radio.GetFreq())));
        }
        else{
            textEstacion.setText(String.valueOf(fmformat.format(radio.GetFreq())));
        }// TODO add your handling code here:
    }//GEN-LAST:event_opt_fmActionPerformed

    private void m1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m1ActionPerformed
        radio.ChangeTune(1);
        if (radio.IsAm()){
            textEstacion.setText(String.valueOf(amformat.format(radio.GetFreq())));
        }
        else{
            textEstacion.setText(String.valueOf(fmformat.format(radio.GetFreq())));
        }// TODO add your handling code here:
    }//GEN-LAST:event_m1ActionPerformed

    private void guardarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_guardarActionPerformed
        radio.SaveFreq(botones.getSelectedIndex()+1);        // TODO add your handling code here:
    }//GEN-LAST:event_guardarActionPerformed

    private void nextActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_nextActionPerformed
        radio.NextFreq();
        if (radio.IsAm()){
            textEstacion.setText(String.valueOf(amformat.format(radio.GetFreq())));
        }
        else{
            textEstacion.setText(String.valueOf(fmformat.format(radio.GetFreq())));
        }
        
        // TODO add your handling code here:
    }//GEN-LAST:event_nextActionPerformed

    private void m2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m2ActionPerformed
        radio.ChangeTune(2);
        if (radio.IsAm()){
            textEstacion.setText(String.valueOf(amformat.format(radio.GetFreq())));
        }
        else{
            textEstacion.setText(String.valueOf(fmformat.format(radio.GetFreq())));
        }        // TODO add your handling code here:
    }//GEN-LAST:event_m2ActionPerformed

    private void m3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m3ActionPerformed
        radio.ChangeTune(3);
        if (radio.IsAm()){
            textEstacion.setText(String.valueOf(amformat.format(radio.GetFreq())));
        }
        else{
            textEstacion.setText(String.valueOf(fmformat.format(radio.GetFreq())));
        }       // TODO add your handling code here:
    }//GEN-LAST:event_m3ActionPerformed

    private void m4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m4ActionPerformed
        radio.ChangeTune(4);
        if (radio.IsAm()){
            textEstacion.setText(String.valueOf(amformat.format(radio.GetFreq())));
        }
        else{
            textEstacion.setText(String.valueOf(fmformat.format(radio.GetFreq())));
        }        // TODO add your handling code here:
    }//GEN-LAST:event_m4ActionPerformed

    private void m5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m5ActionPerformed
        radio.ChangeTune(5);
        if (radio.IsAm()){
            textEstacion.setText(String.valueOf(amformat.format(radio.GetFreq())));
        }
        else{
            textEstacion.setText(String.valueOf(fmformat.format(radio.GetFreq())));
        }        // TODO add your handling code here:
    }//GEN-LAST:event_m5ActionPerformed

    private void m6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m6ActionPerformed
        radio.ChangeTune(6);
        if (radio.IsAm()){
            textEstacion.setText(String.valueOf(amformat.format(radio.GetFreq())));
        }
        else{
            textEstacion.setText(String.valueOf(fmformat.format(radio.GetFreq())));
        }        // TODO add your handling code here:
    }//GEN-LAST:event_m6ActionPerformed

    private void m7ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m7ActionPerformed
        radio.ChangeTune(7);
        if (radio.IsAm()){
            textEstacion.setText(String.valueOf(amformat.format(radio.GetFreq())));
        }
        else{
            textEstacion.setText(String.valueOf(fmformat.format(radio.GetFreq())));
        }        // TODO add your handling code here:
    }//GEN-LAST:event_m7ActionPerformed

    private void m8ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m8ActionPerformed
        radio.ChangeTune(8);
        if (radio.IsAm()){
            textEstacion.setText(String.valueOf(amformat.format(radio.GetFreq())));
        }
        else{
            textEstacion.setText(String.valueOf(fmformat.format(radio.GetFreq())));
        }        // TODO add your handling code here:
    }//GEN-LAST:event_m8ActionPerformed

    private void m9ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m9ActionPerformed
        radio.ChangeTune(9);
        if (radio.IsAm()){
            textEstacion.setText(String.valueOf(amformat.format(radio.GetFreq())));
        }
        else{
            textEstacion.setText(String.valueOf(fmformat.format(radio.GetFreq())));
        }        // TODO add your handling code here:
    }//GEN-LAST:event_m9ActionPerformed

    private void m10ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m10ActionPerformed
        radio.ChangeTune(10);
        if (radio.IsAm()){
            textEstacion.setText(String.valueOf(amformat.format(radio.GetFreq())));
        }
        else{
            textEstacion.setText(String.valueOf(fmformat.format(radio.GetFreq())));
        }        // TODO add your handling code here:
    }//GEN-LAST:event_m10ActionPerformed

    private void m11ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m11ActionPerformed
        radio.ChangeTune(11);
        if (radio.IsAm()){
            textEstacion.setText(String.valueOf(amformat.format(radio.GetFreq())));
        }
        else{
            textEstacion.setText(String.valueOf(fmformat.format(radio.GetFreq())));
        }        // TODO add your handling code here:
    }//GEN-LAST:event_m11ActionPerformed

    private void m12ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m12ActionPerformed
        radio.ChangeTune(12);
        if (radio.IsAm()){
            textEstacion.setText(String.valueOf(amformat.format(radio.GetFreq())));
        }
        else{
            textEstacion.setText(String.valueOf(fmformat.format(radio.GetFreq())));
        }        // TODO add your handling code here:
    }//GEN-LAST:event_m12ActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(UsoRadio.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(UsoRadio.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(UsoRadio.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(UsoRadio.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new UsoRadio().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JComboBox botones;
    private javax.swing.ButtonGroup grp_estacion;
    private javax.swing.JButton guardar;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JButton m1;
    private javax.swing.JButton m10;
    private javax.swing.JButton m11;
    private javax.swing.JButton m12;
    private javax.swing.JButton m2;
    private javax.swing.JButton m3;
    private javax.swing.JButton m4;
    private javax.swing.JButton m5;
    private javax.swing.JButton m6;
    private javax.swing.JButton m7;
    private javax.swing.JButton m8;
    private javax.swing.JButton m9;
    private javax.swing.JButton next;
    private javax.swing.JRadioButton opt_am;
    private javax.swing.JRadioButton opt_fm;
    private javax.swing.JPanel panel1;
    private javax.swing.JPanel panel2;
    private javax.swing.JPanel panel3;
    private javax.swing.JToggleButton power;
    private javax.swing.JTextField textEstacion;
    // End of variables declaration//GEN-END:variables
}
